package com.cskaoyan.service.front.feedback;

import com.cskaoyan.bean.bo.front.feedback.FeedbackBo;
import com.cskaoyan.bean.po.MarketFeedback;
import com.cskaoyan.mapper.MarketFeedbackMapper;
import com.cskaoyan.util.SessionUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * impl反馈服务
 *
 * @author 李然
 * @date 2022/10/14
 */
@Service
public class FeedbackServiceImpl implements FeedbackService{

    @Autowired
    MarketFeedbackMapper marketFeedbackMapper;

    /**
     * 创建反馈
     *
     * @param feedbackBo 传入反馈数据
     * @return int
     */
    @Override
    public int createFeedback(FeedbackBo feedbackBo) {
        Integer id = SessionUtil.getUserInfo().getId();
        String username = SessionUtil.getUserInfo().getUsername();
        MarketFeedback marketFeedback = new MarketFeedback();
        marketFeedback.setUserId(id);
        marketFeedback.setPicUrls(feedbackBo.getPicUrls());
        marketFeedback.setUsername(username);
        marketFeedback.setFeedType(feedbackBo.getFeedType());
        marketFeedback.setContent(feedbackBo.getContent());
        marketFeedback.setHasPicture(feedbackBo.getHasPicture());
        marketFeedback.setMobile(feedbackBo.getMobile());
        marketFeedback.setAddTime(new Date());
        marketFeedback.setUpdateTime(new Date());
        marketFeedbackMapper.insertSelective(marketFeedback);
        return 0;
    }
}
